package com.mls.fivedistrict.server.impl;

import com.github.pagehelper.PageHelper;
import com.mls.fivedistrict.dao.GUserMapper;
import com.mls.fivedistrict.pojo.GUser;
import com.mls.fivedistrict.pojo.GUserExample;
import com.mls.fivedistrict.server.GUserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

/**
 * Created by chenxiuxiang on 2018/4/3.
 */
@Service("gUserService")
public class GUserServiceImpl implements GUserService {
    @Autowired
    GUserMapper gUserMapper;

    @Override
    public int addGUser(GUser gUser) {
        int insert = gUserMapper.insertSelective(gUser);
        return insert;
    }

    @Override
    public GUser getGUserDetail(Long userId) {
        GUserExample gUserExample = new GUserExample();
        GUserExample.Criteria criteria = gUserExample.createCriteria();
        criteria.andUserIdEqualTo(userId);
        List<GUser> gUsers = gUserMapper.selectByExample(gUserExample);
        if (gUsers.size() > 0) {
            return gUsers.get(0);
        }
        return null;
    }
}
